<template>
  <div class="app-container">
    <!-- <p v-html="content"></p> -->
    
    <div class="markdown-body" v-html="markdown"></div>
    
    
    <el-button type="success" @click="pass(articleId)">通过</el-button>

    <el-button type="info" @click="refuse(articleId)">拒绝</el-button>
  </div>
</template>

<script>
import showdown from 'showdown';
import "mavon-editor/dist/css/index.css";
import article from "@/api/article";

export default {
  data() {
    return {
      articleId: "",
      content: "",
      markdown:''
    };
  },

  created() {
    //获取路由的id值
    let that =this;
    if (that.$route.params && that.$route.params.con && that.$route.params.id) {
      that.content = that.$route.params.con;
      that.articleId = that.$route.params.id;

      let converter = new showdown.Converter();
      that.markdown =  converter.makeHtml(that.content);
    }
  },

  methods: {
    pass(articleId) {
      article.pass(articleId).then(response => {
        //提示信息
        this.$message({
          type: "success",
          message: "操作完成"
        });
        //回到列表页面 路由跳转
        this.$router.push({ path: "/article/index" });
      });
    },

    refuse(articleId) {
      article.remove(articleId).then(response => {
        this.$message({
          type: "success",
          message: "操作完成"
        });
        //回到列表页面 路由跳转
        this.$router.push({ path: "/article/index" });
      });
    }
  }
};
</script>
